﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAL;
using System.Data.SqlClient;
using System.Data;

namespace BLL
{
    public class DANHMUCBLL
    {
        DataService DB = new DataService();

        public DataTable getDanhmucForTreeView() {
            string sql = "select * from danhmuc";
            DataTable tb = DB.ExecuteReader(sql);
            return DB.ExecuteReader(sql);
        }

        public void insert(int madanhmuccha, string tendanhmuc)
        {

            string sql = "insert into danhmuc values (@madanhmuccha,@tendanhmuc)";
            SqlParameter paraDMCha = new SqlParameter("madanhmuccha", madanhmuccha);
            SqlParameter paraTemDM = new SqlParameter("tendanhmuc", tendanhmuc);
            DB.ExecuteNonQuery(sql, paraDMCha, paraTemDM);

        }

        public void update(int madanhmuc,int madanhmuccha, string tendanhmuc)
        {

            string sql = "update danhmuc set madanhmuccha = '" + madanhmuccha.ToString() + "', tendanhmuc = '" + tendanhmuc + "' where matinhtrangpm = " + madanhmuc.ToString();
            DB.ExecuteNonQuery(sql);
        }

        public void delete(int madanhmuc)
        {
            string sql = "delete from danhmuc where madanhmuc = " + madanhmuc.ToString();
            DB.ExecuteNonQuery(sql);
        }
    }
}
